﻿using System;
using System.Collections.Generic;
using Infrastructure.kflwyg;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTest
{
    [TestClass]
    public class UnitTestkflwy
    {
        public kflwygHelper kflwygHelper = new kflwygHelper();
        public UnitTestkflwy()
        {

        }

        /// <summary>
        /// 1、上传项目参建单位信息
        /// </summary>
        [TestMethod]
        public void TestImproveProject()
        {
            string result = kflwygHelper.ImproveProject(new ImproveProjectParam
            {
                project_code = "475000200806003208",
                project_lng = "114.14761",
                project_lat = "34.80573",
                tech_corp_name = "河南卓远电子科技有限公司",
                tech_link_man = "宋光辉",
                tech_link_mobile = "17752555111",
            });

            Console.WriteLine(result);
        }

        /// <summary>
        /// 2 上传项目参建单位信息
        /// </summary>
        [TestMethod]
        public void TestAddProjectSub()
        {
            string result = kflwygHelper.AddProjectSub(new AddProjectSubParam()
            {
                project_code = "475000200806003208",
                corp_code = "91410300171072017D",
                corp_name = "河南国安建设集团有限公司",
                corp_type = "009",
                entry_time = "2019-08-20 08:00:00",
                exit_time = "2020-12-31 23:23:59",
                pm_name = "张胜利",
                pm_idcard_type = "1",
                pm_idcard_number = "410329197410293553",
                pm_phone = "13838876065",

                bank_infos = new List<BankInfo>() { new BankInfo() {
                    business_type="001",
                    bank_code="310",
                    bank_name="上海浦东发展银行股份有限公司开封分行",
                    bank_number="18610078801600001286",
                    bank_link_number="310492000011"
                } }
            });

            Console.WriteLine(result);
        }

        /// <summary>
        /// 2、上传班组信息
        /// </summary>
        [TestMethod]
        public void TestAddTeam()
        {
            string result = kflwygHelper.AddTeam(new AddTeamParam()
            {
                corp_code = "91410300171072017D",
                corp_name = "河南国安建设集团有限公司",
                entry_time = "2019-08-20 08:00:00",
                exit_time = "2020-12-31 23:23:59",
                project_code = "475000200806003208",
                remark = "",
                responsible_person_idcard_type = "1",
                responsible_person_idnumber = "410329197410293553",
                responsible_person_name = "张胜利",
                responsible_person_phone = "13838876065",
                team_leader_idcard_type = "1",
                team_leader_idnumber = "410329197410293553",
                team_leader_name = "张胜利",
                team_leader_phone = "13838876065",
                team_name = "国安建设一队"
            });
            Console.WriteLine(result);
        }

        /// <summary>
        /// 3、上传项目工人信息
        /// </summary>
        public void TestAddProjectWorker()
        {
            //工人信息上传
            //SELECT B.Names
            //FROM Worker AS A
            //INNER JOIN dbo.Users AS B ON A.UserID = B.UserID

            string result = kflwygHelper.AddProjectWorker(new AddProjectWorkerParam()
            {
                project_code = "475000200806003208",
                corp_code = "91410300171072017D",
                corp_name = "河南国安建设集团有限公司",
                team_name = "国安建设一队",
                worker_name = "",

            });

            Console.WriteLine(result);
        }

        public void TestDeleteProjectWorker()
        {
            string project_code = "";
            string corp_code = "";
            string team_name = "";
            string idcard_number = "";
            string result = kflwygHelper.DeleteProjectWorker(project_code, corp_code, team_name, idcard_number);

        }

        /// <summary>
        /// 上传工人考勤
        /// </summary>
        public void TestAddWorkerAttendance()
        {

            //---考勤信息上传
            //SELECT A.*, B.Names, B.ICNum, B.IDCardType
            //FROM(
            //    SELECT UserID,
            //           CONVERT(NVARCHAR(10), ClassDate, 120) + ' ' + CONVERT(NVARCHAR(10), ISNULL(BeginTime2, '')) AS 'date',
            //           '1' AS direction, '' AS channel, '001' AS attend_type, '0' AS lng, '0' AS lat
            //    FROM Attendance
            //    WHERE BeginTime2 IS NOT NULL
            //    UNION
            //    SELECT UserID, CONVERT(NVARCHAR(10), ClassDate, 120) + ' ' + CONVERT(NVARCHAR(10), ISNULL(EndTime2, '')) AS 'date',
            //           '0' AS direction, '' AS channel, '001' AS attend_type, '0' AS lng, '0' AS lat
            //    FROM Attendance
            //    WHERE EndTime2 IS NOT NULL
            //) AS A
            //    INNER JOIN dbo.Users AS B ON A.UserID = B.UserID
            //WHERE B.ICNum IS NOT NULL  
            //

            string result = kflwygHelper.AddWorkerAttendance(new AddWorkerAttendanceParam()
            {
                project_code = "475000200806003208",
                corp_code = "91410300171072017D",
                corp_name = "河南国安建设集团有限公司",
                team_name = "国安建设一队",
                idcard_type = "1",
                idcard_number = "",
                date = "",
                direction = "",
                channel = "",
                attend_type = "",
                lng = "",
                lat = "",

            });

            Console.WriteLine(result);
        }
    }
}
